package linkedlistdemo;

/**
 * Created with IntelliJ IDEA
 * Description
 * User：chenshu
 * Date：2023-11-11
 * Time：23:13
 */
public class Demo1 {
    public static void main(String[] args) {
        MyLinkedList myLinkedList = new MyLinkedList();
        myLinkedList.addLast(3);
        myLinkedList.addLast(3);
        myLinkedList.addLast(3);
        myLinkedList.addLast(3);
        myLinkedList.addLast(3);
        myLinkedList.addLast(3);
        myLinkedList.display();
        System.out.println("=================");
        myLinkedList.clear();
        myLinkedList.display();
    }
    public static void main5(String[] args) {
        MyLinkedList myLinkedList = new MyLinkedList();
        myLinkedList.addLast(3);
        myLinkedList.addLast(3);
        myLinkedList.addLast(3);
        myLinkedList.addLast(3);
        myLinkedList.addLast(3);
        myLinkedList.addLast(3);
        myLinkedList.addLast(1);
        myLinkedList.addLast(3);
        myLinkedList.display();
        System.out.println("=================");
        myLinkedList.removeAllKey(3);
        myLinkedList.display();
    }
    public static void main4(String[] args) {
        MyLinkedList myLinkedList = new MyLinkedList();
        myLinkedList.addLast(1);
        myLinkedList.addLast(2);
        myLinkedList.addLast(3);
        myLinkedList.addLast(4);
        myLinkedList.display();
        System.out.println("=================");
        //删头
        myLinkedList.remove(1);
        //删中间
        myLinkedList.remove(3);
        //删尾
        myLinkedList.remove(4);
        myLinkedList.display();
        System.out.println("=================");
        //删最后一个节点
        myLinkedList.remove(2);
        myLinkedList.display();
    }
    public static void main3(String[] args) {
        MyLinkedList myLinkedList = new MyLinkedList();
        myLinkedList.addIndex(0,1);
        myLinkedList.addIndex(1,2);
        myLinkedList.addIndex(1,3);
        myLinkedList.addIndex(2,4);
        myLinkedList.display();
    }
    public static void main2(String[] args) {
        MyLinkedList myLinkedList = new MyLinkedList();
        myLinkedList.addLast(1);
        myLinkedList.addLast(2);
        myLinkedList.addLast(3);
        myLinkedList.addLast(4);
        myLinkedList.display();
    }
    public static void main1(String[] args) {
        MyLinkedList myLinkedList = new MyLinkedList();
        myLinkedList.addFirst(1);
        myLinkedList.addFirst(2);
        myLinkedList.addFirst(3);
        myLinkedList.addFirst(4);
        myLinkedList.display();
    }
}
